﻿        function getComments(reviewId) {
        var date = new Date();
        $.ajax({
                url: '/CodeDemon/Review/DisplayReviewComments',
                data: 'reviewId=' + reviewId +'&amp;time=' + date.getTime(),
                type: 'POST',
                dataType: 'html',
                timeout: 20000,
            error: function(){
                alert('Error loading the comments in getComments()');
            },
            success: function(TheHtml){
                $('#commentContainer').html(TheHtml).show('1');
            }
            });
        }
        
        
        function getReviewFileComments(fileId) {
        var date = new Date();
        $.ajax({
                url: '/CodeDemon/Review/DisplayFileComments',
                data: 'reviewFileId=' + fileId+'&amp;time=' + date.getTime(),
                type: 'POST',
                dataType: 'html',
                timeout: 20000,
            error: function(){
                alert('Error loading the comments in getReviewFileComments()');
            },
            success: function(TheHtml){
                $('#commentContainer_' + fileId ).html(TheHtml).show('1');
            }
            });
        }
        
        function getReviewFileLineComments(fileId,lineNumber) {
        var date = new Date();
        $.ajax({
                url: '/CodeDemon/Review/DisplayFileLineComments',
                data: 'reviewFileId=' + fileId + '&lineNumber=' + lineNumber+'&amp;time=' + date.getTime(),
                type: 'POST',
                dataType: 'html',
                timeout: 20000,
            error: function(){
                alert('Error loading the comments in getReviewFileLineComments()');
            },
            success: function(TheHtml){
                $('#commentContainer_' + fileId + '_' + lineNumber ).html(TheHtml).show('1');
            }
            });
        }
        
        function GetRevisionFiles ( revisionId ) {
        var date = new Date();
        $('#showFileList' + revisionId).click(function() {
             $.ajax({
                    url: '/CodeDemon/Builder/DisplayRevisionFiles',
                    data: 'revisionID=' + revisionId+'&amp;time=' + date.getTime(),
                    type: 'POST',
                    dataType: 'html',
                    timeout: 20000,
                error: function(){
                    alert('Error loading the changes in GetRevisionFiles()');
                },
                success: function(TheHtml){
                    $('#fileList' + revisionId).html(TheHtml).show('1');
                    $('#showFileList' + revisionId).click(function() {
                        $('#fileList' + revisionId).show('1');    
                        $('#hideFileList' + revisionId).show();
                        $('#showFileList' + revisionId).hide();
                    });
                    $('#hideFileList' + revisionId).show();
                    $('#showFileList' + revisionId).hide();
                }
            });                         
           });
           
           $('#hideFileList' + revisionId).click(function() { 
                 $('#fileList' + revisionId).hide('1');    
                 $('#hideFileList' + revisionId).hide();
                 $('#showFileList' + revisionId).show();         
           });               
        }
        
        function  ReadyReview( CurrentReviewID ) {
            var date = new Date();
            $('#reviewLogBlock').hide();
            $('#hideReviewLog').click(function() { 
                $('#reviewLogBlock').hide('1');
                $('#showReviewLog').show();
                $('#hideReviewLog').hide();
            });
        
            $('#hideReviewLog').hide();
            $('#showReviewLog').click(function() {
            $.ajax({
                url: '/CodeDemon/Review/DisplayReviewLog',
                data: 'reviewId=' + CurrentReviewID+'&amp;time=' + date.getTime(),
                type: 'POST',
                dataType: 'html',
                timeout: 20000,
                error: function(){
                    alert('Error loading your diff in ReadyReview()');
                },
                success: function(TheHtml){
                    $('#reviewLogBlock').html(TheHtml).show('1');
                    $('#showReviewLog').click(function() {
                        $('#reviewLogBlock').show('1');
                    });
                    $('#showReviewLog').hide();
                    $('#hideReviewLog').show();
                    }
                });
            });
            $('#ex2').jqm({ ajax: '/CodeDemon/Review/NewReviewComment?reviewId=' + CurrentReviewID + '&amp;time=' + date.getTime(), trigger: 'a.ex2trigger', overlay: 50, modal: 1, ajaxText: '<div style="display:block;text-align: center; margin: 50px 0 0 280px ; width:18em;"><img src="/images/spinner-big.gif" /><br/><br/><span class="loading">Loading...</span><br/><br/><br/></div>' });
            $('#ex3').jqm({ ajax: '/CodeDemon/Review/EditReview?reviewId=' + CurrentReviewID + '&amp;time=' + date.getTime(), trigger: 'a.ex3trigger', overlay: 50, modal: 1, ajaxText: '<div style="display:block;text-align: center; margin: 50px 0 0 280px ; width:18em;"><img src="/images/spinner-big.gif" /><br/><br/><span class="loading">Loading...</span><br/><br/><br/></div>' });
            $('#ex4').jqm({ ajax: '/CodeDemon/Review/EditApprovalStatus?reviewID=' + CurrentReviewID + '&amp;time=' + date.getTime(), trigger: 'a.ex4trigger', overlay: 50, modal: 1, ajaxText: '<div style="display:block;text-align: center; margin: 50px 0 0 280px ; width:18em;"><img src="/images/spinner-big.gif" /><br/><br/><span class="loading">Loading...</span><br/><br/><br/></div>' });

            $('#ex_join_as_cc').jqm({ ajax: '/CodeDemon/Review/JoinReview?reviewId=' + CurrentReviewID + '&asReviewer=false' + '&amp;time=' + date.getTime(), trigger: 'a.ex_join_as_cc_trigger', overlay: 50, modal: 1, ajaxText: '<div style="display:block;text-align: center; margin: 50px 0 0 280px ; width:18em;"><img src="/images/spinner-big.gif" /><br/><br/><span class="loading">Loading...</span><br/><br/><br/></div>' });
            $('#ex_join_as_rev').jqm({ ajax: '/CodeDemon/Review/JoinReview?reviewId=' + CurrentReviewID + '&asReviewer=true' + '&amp;time=' + date.getTime(), trigger: 'a.ex_join_as_rev_trigger', overlay: 50, modal: 1, ajaxText: '<div style="display:block;text-align: center; margin: 50px 0 0 280px ; width:18em;"><img src="/images/spinner-big.gif" /><br/><br/><span class="loading">Loading...</span><br/><br/><br/></div>' });
        }
        
        function ReadyBinaryFile ( ReviewFileID ) {
             $('#hidelogicon' + ReviewFileID).hide();
             $('#logicon' + ReviewFileID).click(function() {
                    $('#msg' + ReviewFileID).show('1');
                    $('#logicon' + ReviewFileID).hide();
                    $('#hidelogicon' + ReviewFileID).show();
             });
             $('#hidelogicon' + ReviewFileID).click(function() {
                    $('#msg' + ReviewFileID).hide('1');
                    $('#logicon' + ReviewFileID).show();
                    $('#hidelogicon' + ReviewFileID).hide();
             });
             
            $('#div' + ReviewFileID).hide();
            $('#msg' + ReviewFileID).hide();
        }
        function ReadyReviewFile( ReviewFileID ) {
             $('#hidelogicon' + ReviewFileID).hide();
             $('#logicon' + ReviewFileID).click(function() {
                    $('#msg' + ReviewFileID).show('1');
                    $('#logicon' + ReviewFileID).hide();
                    $('#hidelogicon' + ReviewFileID).show();
             });
             $('#hidelogicon' + ReviewFileID).click(function() {
                    $('#msg' + ReviewFileID).hide('1');
                    $('#logicon' + ReviewFileID).show();
                    $('#hidelogicon' + ReviewFileID).hide();
             });
             
        $('#div' + ReviewFileID).hide();
        $('#msg' + ReviewFileID).hide();
        $('#hide' + ReviewFileID).hide();
        $('#hide' + ReviewFileID).click(function() {
            $('#div' + ReviewFileID).hide('1');
            $('#show' + ReviewFileID).click(function() {
            $('#div' + ReviewFileID).show('1');
            $('#arrow' + ReviewFileID).attr("src", "/CodeDemon/Content/arrow_open.gif");
            $('#arrow2' + ReviewFileID).attr("src", "/CodeDemon/Content/arrow_open.gif");
            });
            $('#show' + ReviewFileID).show();
            $('#hide' + ReviewFileID).hide();
            $('#arrow' + ReviewFileID).attr("src", "/CodeDemon/Content/arrow_closed.gif");
            $('#arrow2' + ReviewFileID).attr("src", "/CodeDemon/Content/arrow_closed.gif");
        });
        var date = new Date();
        $('#show' + ReviewFileID).click(function() {
                $('#div' + ReviewFileID).show();
                $.ajax({
                url: '/CodeDemon/Review/DisplayReviewFile',
                data: 'reviewFileId=' + ReviewFileID+'&amp;time=' + date.getTime(),
                type: 'POST',
                dataType: 'html',
                timeout: 20000,
            error: function(){
                alert('Error loading your diff in ReadyReviewFile()');
            },
            success: function(TheHtml){
                $('#div' + ReviewFileID).html(TheHtml).show('1');
                $('#show' + ReviewFileID).hide();
                $('#hide' + ReviewFileID).show();
                $('#arrow' + ReviewFileID).attr("src", "/CodeDemon/Content/arrow_open.gif");
                $('#arrow2' + ReviewFileID).attr("src", "/CodeDemon/Content/arrow_open.gif");
                getReviewFileComments('' + ReviewFileID);
                $('#ex' + ReviewFileID).jqm({ ajax: '/CodeDemon/Review/NewReviewFileComment?reviewFileId=' + ReviewFileID + '&lineNumber=-1' + '&amp;time=' + date.getTime(), trigger: 'a.commentTrigger' + ReviewFileID, overlay: 50, modal: 1, ajaxText: '<div style="display:block;text-align: center; margin: 50px 0 0 280px ; width:18em;"><img src="/images/spinner-big.gif" /><br/><br/><span class="loading">Loading...</span><br/><br/><br/></div>' });
            }
        });
        });
      }
             





function ReadyReviewFileSingle( ReviewFileID ) {
             $('#hidelogicon' + ReviewFileID).hide();
             $('#logicon' + ReviewFileID).click(function() {
                    $('#msg' + ReviewFileID).show('1');
                    $('#logicon' + ReviewFileID).hide();
                    $('#hidelogicon' + ReviewFileID).show();
             });
             $('#hidelogicon' + ReviewFileID).click(function() {
                    $('#msg' + ReviewFileID).hide('1');
                    $('#logicon' + ReviewFileID).show();
                    $('#hidelogicon' + ReviewFileID).hide();
             });
             
        $('#div' + ReviewFileID).hide();
        $('#msg' + ReviewFileID).hide();
        $('#hide' + ReviewFileID).hide();
        $('#hide' + ReviewFileID).click(function() {
            $('#div' + ReviewFileID).hide('1');
            $('#show' + ReviewFileID).click(function() {
            $('#div' + ReviewFileID).show('1');
            $('#arrow' + ReviewFileID).attr("src", "/CodeDemon/Content/arrow_open.gif");
            $('#arrow2' + ReviewFileID).attr("src", "/CodeDemon/Content/arrow_open.gif");
            });
            $('#show' + ReviewFileID).show();
            $('#hide' + ReviewFileID).hide();
            $('#arrow' + ReviewFileID).attr("src", "/CodeDemon/Content/arrow_closed.gif");
            $('#arrow2' + ReviewFileID).attr("src", "/CodeDemon/Content/arrow_closed.gif");
        });
        var date = new Date();
        
                $('#div' + ReviewFileID).show();
                $.ajax({
                url: '/CodeDemon/Review/DisplayReviewFile',
                data: 'reviewFileId=' + ReviewFileID+'&amp;time=' + date.getTime(),
                type: 'POST',
                dataType: 'html',
                timeout: 20000,
            error: function(){
                alert('Error loading your diff in ReadyReviewFileSingle()');
            },
            success: function(TheHtml){
                $('#div' + ReviewFileID).html(TheHtml).show('1');
                $('#show' + ReviewFileID).hide();
                $('#hide' + ReviewFileID).show();
                $('#arrow' + ReviewFileID).attr("src", "/CodeDemon/Content/arrow_open.gif");
                $('#arrow2' + ReviewFileID).attr("src", "/CodeDemon/Content/arrow_open.gif");
                getReviewFileComments('' + ReviewFileID);
                $('#ex' + ReviewFileID).jqm({ ajax: '/CodeDemon/Review/NewReviewFileComment?reviewFileId=' + ReviewFileID + '&lineNumber=-1' + '&amp;time=' + date.getTime(), trigger: 'a.commentTrigger' + ReviewFileID, overlay: 50, modal: 1, ajaxText: '<div style="display:block;text-align: center; margin: 50px 0 0 280px ; width:18em;"><img src="/images/spinner-big.gif" /><br/><br/><span class="loading">Loading...</span><br/><br/><br/></div>' });
            }
        
        });
      }


/* Project Functions */

      
      function readyProjectPhase( ProjectPhaseID, ProjectID ) {
            $('#collapse' + ProjectPhaseID).click(function() {
                     $('#phaseBody' + ProjectPhaseID ).hide('1');
                         $('#expand' + ProjectPhaseID).show(); 
                         $('#collapse' + ProjectPhaseID).hide();
                     
                     });
                $('#expand' + ProjectPhaseID).click(function() {
                        PostProjectPhaseHTML(ProjectPhaseID, ProjectID);
                        $('#collapse' + ProjectPhaseID).show();
                });
      }
      
      function PostProjectPhaseHTML( ProjectPhaseID, ProjectID ) {
      var date = new Date();
                  $.ajax({
                     url: '/CodeDemon/Project/DisplayProjectPhase',
                     data: 'projectPhaseID=' + ProjectPhaseID + '&projectID=' + ProjectID + '&time=' + date.getTime(),
                     type: 'POST',
                     dataType: 'html',
                     timeout: 20000,
                     error: function(){
                        alert('Error loading the comments in getProjectPhase()');
                     },
                     success: function(TheHtml){
                        $('#phaseBody' + ProjectPhaseID ).html(TheHtml).show('1');
                        $('#expand' + ProjectPhaseID).hide();
                        $('#expand' + ProjectPhaseID).click(function(){ 
                           $('#expand' + ProjectPhaseID).hide(); 
                           $('#collapse' + ProjectPhaseID).show(); 
                        });
                    }
           });
      }
      
      function loadSVNTree( SvnUrl ) {
        var date = new Date();
        $.ajax({
           url: '/CodeDemon/Project/DisplaySVNTree',
           data: 'theURL=' + SvnUrl +'&time=' + date.getTime(),
           type: 'POST',
           dataType: 'html',
           timeout: 20000,
           error: function(){
              alert('Error loading the comments in loadSVNTree()');
           },
           success: function(TheHtml){
            $('#svn_browser').html(TheHtml).show('1');
           }
       });
      }
             
